<html>
<head>
    <th:block th:include="include :: headermain('互助保障系统V3')"/>
    <script src="/plugin/jquery/jquery.min.js"></script>
    <script src="/plugin/jquery/jquery.plugin.js"></script>
    <script src="/plugin/vue/vue.min.js"></script>
    <script src="/plugin/layui/layui.all.js"></script>
    <script src="/unit/resource/js/script.js"></script>
    <title>会员花名册</title>
</head>
<body style="padding:15px;">
<input type="hidden" name="id" value="${hzPolicyInsurance.id}" />
<div class="page-form-item">
    <div class="page-form-input">
        <input type="text" style="width:80px" placeholder="姓名" value="${personName}" id="personName" name="name">
    </div>
    <div class="page-form-input">
        <input type="text" style="width:180px" placeholder="身份证号码" value="${idCard}" id="idCard" name="idCard">
    </div>
    <div class="page-form-input">
        <button type="button" class="layui-btn" onclick="getPersonRoster(${page.pageNo},10)">查询</button>
        <c:if test="${empty hzPolicy.stepid}">
            <button type="button" class="layui-btn layui-btn-normal" onclick="addPolicyPerson()">添加会员</button>
        </c:if>
    </div>
</div>

<table class="page-table" style="margin-top:15px;">
    <tbody>
    <tr>
        <th style="width:50px;">序号</th>
        <th>姓名</th>
        <th style="width:50px;">性别</th>
        <th>证件号码</th>
        <th>手机</th>
        <th>邮箱</th>
        <th>是否高级或处级以上干部</th>
        <th>金额</th>
        <th>状态</th>
        <c:if test="${empty hzPolicy.stepid}">
            <th>操作</th>
        </c:if>
    </tr>
    <c:forEach items="${page.list}" var="policyPerson" varStatus="policyPersons">
        <tr>
            <td style="width:50px;">${policyPersons.index + 1}</td>
            <td>${policyPerson.person.name}</td>
            <td style="width:50px;">
                <c:choose>
                    <c:when test="${policyPerson.person.sex == 1}">
                        男
                    </c:when>
                    <c:when test="${policyPerson.person.sex == 2}">
                        女
                    </c:when>
                    <c:otherwise>
                        保密
                    </c:otherwise>
                </c:choose>
            </td>
            <td>${policyPerson.person.idCard}</td>
            <td>${policyPerson.person.mobile}</td>
            <td>${policyPerson.person.email}</td>
            <td>
                <c:choose>
                    <c:when test="${policyPerson.person.isSenior == '1'}">
                        是
                    </c:when>
                    <c:when test="${policyPerson.person.isSenior == '0'}">
                        否
                    </c:when>
                    <c:otherwise>
                        未知
                    </c:otherwise>
                </c:choose>
            </td>
            <td>${policyPerson.amount}</td>
            <td>
                <c:choose>
                    <c:when test="${policyPerson.retireqty == 1}">
                        退休续互
                    </c:when>
                    <c:when test="${policyPerson.newqty == 1}">
                        新入会
                    </c:when>
                    <c:when test="${policyPerson.renewqty == 1}">
                        重新入会
                    </c:when>
                    <c:otherwise>
                        续互
                    </c:otherwise>
                </c:choose>
            </td>
            <c:if test="${empty hzPolicy.stepid}">
                <td>
                    <a class="layui-btn layui-btn-sm layui-btn-danger policy-person-btn-del" data-id="${policyPerson.person.id}">删除</a>
                </td>
            </c:if>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="page-pagination">
    <!--    当前页之前 -->
    <span>共${page.count}条记录 ${page.pageNo}/${page.last}</span>
    <c:choose>
        <c:when test="${page.pageNo == 1}">
            <span>首页</span>
            <span>上一页</span>
        </c:when>
        <c:otherwise>
            <a onclick="getPersonRoster(1,10)">  首页</a>
            <a onclick="getPersonRoster(${page.pageNo-1},10)">上一页</a>
            <c:choose>
                <c:when test="${(page.pageNo - 5) > 0}">
                    <c:forEach step="1" begin="${page.pageNo-5}" end="${page.pageNo-1}" varStatus="status">
                        <a onclick="getPersonRoster(${begin+status.index},10)">${begin+status.index}</a>
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    <c:forEach step="1" begin="1" end="${page.pageNo-1}" varStatus="status">
                        <a onclick="getPersonRoster(${begin+status.index},10)">${begin+status.index}</a>
                    </c:forEach>
                </c:otherwise>
            </c:choose>
        </c:otherwise>
    </c:choose>
    <!--      当前页 -->
    <span>${page.pageNo}</span>
    <!--  当前页之后 -->
    <c:choose>
        <c:when test="${page.pageNo == page.last}">
            <span>下一页</span>
            <span>尾页</span>
        </c:when>
        <c:otherwise>
            <a onclick="getPersonRoster(${page.pageNo + 1},10)">${page.pageNo + 1}</a>
            <a onclick="getPersonRoster(${page.pageNo + 1},10)">  下一页</a>
            <a onclick="getPersonRoster(${page.last},10)">尾页</a>
        </c:otherwise>
    </c:choose>
</div>

<script type="text/javascript">
    function getPersonRoster(pageNo, pageSize){
        var personName = $('#personName').val();
        var idCard = $('#idCard').val();
        window.location = "/hzpolicy/hzPolicyFront/personRosterData?pageNo="+ pageNo +"&pageSize="+ pageSize +"&id=${hzPolicyInsurance.id}&name="+personName+"&idCard="+idCard;
    }

    /* 取消会员入会 */
    $(".policy-person-btn-del").click(function () {
        var personId = $(this).attr("data-id");
        layer.confirm('确实要取消该会员的入会申请吗？', {
            btn: ['删除', '取消']
        }, function () {
            $.soon.ajax({
                url: "/hzpolicy/hzPolicyFront/delPolicyPerson?personId=" + personId + "&insuranceId=${hzPolicyInsurance.id}",
                success: function (data) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000);
                }
            });
        });
    });

    /* 添加会员 */
    function addPolicyPerson(pageNo, pageSize){
        $.soon.open({
            url: "/hzpolicy/hzPolicyFront/addPolicyPerson?insuranceId=${hzPolicyInsurance.id}",
            width: "70%",
            height: "80%",
            title: '添加职工',
            offset: 't',
            btn: ['确认', '取消'],
            end:function () {
                window.location.reload();
            }
        });
    }

    //关闭按钮
    /* $(document).on('click', '.layui-layer-close1', function(e){
        alert(1)
        //window.parent.location.reload();
    }) */
</script>
</body>
</html>